<HTML>
<HEAD>
<TITLE>[Chapter 19] FlowLayout</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 15:12:20 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_22.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 19<br>java.awt Reference</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch19_24.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>FlowLayout</H1>

<H2>Name</H2>

FlowLayout

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch19-REFSECT1-AUTOID.23"></A></h2>
</DIV>


<p>
<img align=middle src="./figs/flowlay.gif" alt="[Graphic: Figure from the text]" width=502 height=77 border=0>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-1">Description</A></h2>

<P CLASS=para>
The <tt CLASS=literal>FlowLayout</tt> <tt CLASS=literal>LayoutManager</tt> 
provides the means to lay out components in a row by row fashion. As each 
row fills up, the components continue on the next row. 

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-2">Class Definition</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public class java.awt.FlowLayout
    extends java.lang.Object
    implements java.awt.LayoutManager, java.io.Serializable {
  
  // Constants
  public static final int CENTER;
  public static final int LEFT;
  public static final int RIGHT;
  
  // Constructors
  public FlowLayout();
  public FlowLayout (int alignment);
  public FlowLayout (int alignment, int hgap, int vgap);
  
  // Instance Methods
  public void addLayoutComponent (String name, Component component); 
  public int getAlignment(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public int getHgap(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public int getVgap(); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void layoutContainer (Container target); 
  public Dimension minimumLayoutSize (Container target); 
  public Dimension preferredLayoutSize (Container target); 
  public void removeLayoutComponent (Component component); 
  public void setAlignment (int align); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setHgap (int hgap); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public void setVgap (int vgap); <img src="gifs/bstar.gif" alt="(New)" border=0>
  public String toString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.1">CENTER</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.1.1">public static final int CENTER</A></h4>

<P CLASS=para>
The default alignment for a <tt CLASS=literal>FlowLayout</tt> 
object; rows of components are centered within the container. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.2">LEFT</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.2.1">public static final int LEFT</A></h4>

<P CLASS=para>
An alignment for a <tt CLASS=literal>FlowLayout</tt> 
object; rows of components start on the left side of the container. 

</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.3">RIGHT</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-3.3.1">public static final int RIGHT</A></h4>

<P CLASS=para>
An alignment for a <tt CLASS=literal>FlowLayout</tt> 
object; rows of components start on the right side of the container. 

</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-4">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-4.1">FlowLayout</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-4.1.1">public FlowLayout()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>FlowLayout</tt> object 
with <tt CLASS=literal>CENTER</tt> alignment. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-4.1.2">public FlowLayout (int alignment)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>alignment</I><br>
<DD>

<P CLASS=para>
Alignment of components within the container.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>FlowLayout</tt> object 
with the given <tt CLASS=literal>alignment</tt>. </DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-4.1.3">public FlowLayout (int alignment, int hgap, int vgap)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>alignment</I><br>
<DD>

<P CLASS=para>
Alignment of components within container 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>hgap</I><br>
<DD>

<P CLASS=para>
Horizontal space between each component in a row 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>vgap</I><br>
<DD>

<P CLASS=para>
Vertical space between each row </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs a <tt CLASS=literal>FlowLayout</tt> object 
with the given <tt CLASS=literal>alignment</tt> and 
the values specified as the gaps between each component in the container 
managed by this instance of <tt CLASS=literal>FlowLayout</tt>. </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.1">addLayoutComponent</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.1.1">public void addLayoutComponent (String name, Component component)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>name</I><br>
<DD>

<P CLASS=para>
Name of component to 
add. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>component</I><br>
<DD>

<P CLASS=para>
Actual component 
being added. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>LayoutManager.addLayoutComponent()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Does nothing. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.2">getAlignment</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.2.1">public int getAlignment() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The alignment constant for this <tt CLASS=literal>FlowLayout</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.3">getHgap</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.3.1">public int getHgap() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The horizontal gap between components. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.4">getVgap</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.4.1">public int getVgap() <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The vertical gap between components. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.5">layoutContainer</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.5.1">public void layoutContainer (Container target)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>target</I><br>
<DD>

<P CLASS=para>
The container that needs to be redrawn. </DL>
<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>LayoutManager.layoutContainer()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Draws the components contained within the <tt CLASS=literal>target</tt> 
container. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.6">minimumLayoutSize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.6.1">public Dimension minimumLayoutSize (Container target)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>target</I><br>
<DD>

<P CLASS=para>
The container whose 
size needs to be calculated. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Minimum <tt CLASS=literal>Dimension</tt> of container 
<tt CLASS=literal>target</tt> 

<p>
<DT CLASS=varlistentry>Implements<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>LayoutManager.minimumLayoutSize()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Calculates minimum size of <tt CLASS=literal>target</tt> 
container. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.7">preferredLayoutSize</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.7.1">public Dimension preferredLayoutSize (Container target)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>target</I><br>
<DD>

<P CLASS=para>
The container whose 
size needs to be calculated. </DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
Preferred <tt CLASS=literal>Dimension</tt> of container 
<tt CLASS=literal>target</tt> 

<p>
<DT CLASS=varlistentry>Implements <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>LayoutManager.preferredLayoutSize()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Calculates preferred size of <tt CLASS=literal>target</tt> 
container. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.8">removeLayoutComponent</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.8.1">public void removeLayoutComponent (Component component)</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>component</I><br>
<DD>

<P CLASS=para>
Component to stop tracking. </DL>
<p>
<DT CLASS=varlistentry>Implements <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>LayoutManager.removeLayoutComponent()</tt> 

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Does nothing. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.9">setAlignment</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.9.1">public void setAlignment(int align) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>alignment</I><br>
<DD>

<P CLASS=para>
Alignment of components within container </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Sets the alignment for the <tt CLASS=literal>FlowLayout</tt>. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.10">setHgap</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.10.1">public void setHgap(int hgap) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>hgap</I><br>
<DD>

<P CLASS=para>
The horizontal gap value. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Sets the horizontal gap between components. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.11">setVgap</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.11.1">public void setVgap(int vgap) <img src="gifs/bstar.gif" alt="(New)" border=0></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>vgap</I><br>
<DD>

<P CLASS=para>
The vertical gap value. </DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Sets the vertical gap between components. </DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.12">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-5.12.1">public String toString()</A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string representation of the <tt CLASS=literal>FlowLayout</tt> 
object. 

<p>
<DT CLASS=varlistentry>Overrides <br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt> </DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="JAWT-CH-19-REF-FLOWLAYOUT-SECT-6">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>Component</tt>, <tt CLASS=literal>Container</tt>, 
<tt CLASS=literal>Dimension</tt>, <tt CLASS=literal>LayoutManager</tt>, 
<tt CLASS=literal>Object</tt>, <tt CLASS=literal>Serializable</tt>, 
<tt CLASS=literal>String</tt> 

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch19_22.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch19_24.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>FileDialog</td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>Font</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
